package com.dlc.yunguang.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import butterknife.BindView;
import com.dlc.commonlibrary.widget.TitleBar;
import com.dlc.yunguang.adapter.FragmentViewPagerAdapter;
import com.dlc.yunguang.base.BaseActivity;
import com.dlc.yunguang.R;
import com.dlc.yunguang.fragment.BackWashOddFragment;
import com.dlc.yunguang.fragment.ReturnFragment;
import com.dlc.yunguang.fragment.SendDistributeFragment;
import com.dlc.yunguang.fragment.SendGoodsOddFragment;
import com.dlc.yunguang.fragment.SendRecycleFragment;
import com.dlc.yunguang.fragment.SendWashOddFragment;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by kawaimisashi on 2017/7/19 0019.
 */

public class OrderManageActivity extends BaseActivity {
    @BindView(R.id.viewpager)
    ViewPager viewPager;
    @BindView(R.id.tab_layout)
    TabLayout tab_layout;
    @BindView(R.id.titleBar)
    TitleBar titleBar;
    /*    @BindView(R.id.tabStrip)
        PagerTitleStrip tabStrip;*/
    private static final String[] titles = new String[]{"送洗单","返洗单", "送货单","分发单","回收单","退货单"};
    //private static final String[] titles = new String[]{"送洗单","返洗单", "送货单"};
    private List<String> mDataList = Arrays.asList(titles);
    private List<Fragment> fragments=new ArrayList<>();
    private FragmentViewPagerAdapter fragmentAdapter;
    protected int getLayoutID() {
        return R.layout.activity_order_manage;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        titleBar.leftExit(this);
        initFragment();
        //设置TabLayout的模式
        tab_layout.setTabMode(TabLayout.MODE_FIXED);
        tab_layout.setTabTextColors(getResources().getColor(R.color.page_bg), Color.WHITE);
        //将viewpager与TabLayout绑定
        tab_layout.setupWithViewPager(viewPager);
        fragmentAdapter = new FragmentViewPagerAdapter(getSupportFragmentManager(),
            fragments,mDataList );
        viewPager.setAdapter(fragmentAdapter);
    }
    private void initFragment() {
        fragments.add(new SendWashOddFragment());
        fragments.add(new BackWashOddFragment());
        fragments.add(new SendGoodsOddFragment());
        fragments.add(new SendDistributeFragment());
        fragments.add(new SendRecycleFragment());
        fragments.add(new ReturnFragment());
    }

}
